﻿using StudentCourses;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace TestProjectStudentCourses
{
    [TestClass()]
    public class StudentTest
    {
        [TestMethod()]
        [ExpectedException(typeof(ArgumentNullException))]
        public void StudentConstructorTestNullName()
        {
            string name = null; 
            int facultyNumber = 12345;
            Student target = new Student(name, facultyNumber);
        }

        [TestMethod()]
        public void StudentConstructorTest()
        {
            string name = "Elena";
            int facultyNumber = 12345;
            Student target = new Student(name, facultyNumber);
        }

        [TestMethod()]
        [ExpectedException(typeof(ArgumentNullException))]
        public void StudentConstructorTestEmptyName()
        {
            string name = string.Empty;
            int facultyNumber = 12345;
            Student target = new Student(name, facultyNumber);
        }

        
        [TestMethod()]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void StudentConstructorTestSmallFN()
        {
            string name = null; 
            int facultyNumber = 12;
            Student target = new Student(name, facultyNumber);
        }

        [TestMethod()]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void StudentConstructorTestBigFN()
        {
            string name = null;
            int facultyNumber = 123456;
            Student target = new Student(name, facultyNumber);
        }

        [TestMethod()]
        public void EqualsTestSameFN()
        {
            string name = "Elena"; 
            int facultyNumber = 12345;
            Student target = new Student(name, facultyNumber); 
            object obj = new Student("Iva", 12345);
            bool expected = true; 
            bool actual;
            actual = target.Equals(obj);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void EqualsTestDifferentFN()
        {
            string name = "Elena";
            int facultyNumber = 12344;
            Student target = new Student(name, facultyNumber);
            object obj = new Student("Iva", 12345);
            bool expected = false;
            bool actual;
            actual = target.Equals(obj);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void GetHashCodeTest()
        {
            string name = "Elena";
            int facultyNumber = 12345; 
            Student target = new Student(name, facultyNumber); 
            int expected = facultyNumber.GetHashCode(); 
            int actual;
            actual = target.GetHashCode();
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [DeploymentItem("StudentCourses.exe")]
        public void NameTest()
        {
            String name = "Pesho";
            Student s = new Student(name, 22222);
            Assert.AreEqual(s.Name, name);
        }
    }
}
